package com.gopay.bis.manager.bank.payconfig.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.gopay.bis.dao.payconfig.BisBankSpecialMerchantsDao;
import com.gopay.bis.domain.order.SpecialMerchants;
import com.gopay.bis.manager.bank.payconfig.BisBankSpecialMerchantsManager;

@Service("bisBankSpecialMerchantsManager")
public class BisBankSpecialMerchantsManagerImpl implements
		BisBankSpecialMerchantsManager {
	@Resource(name="bisBankSpecialMerchantsDao")
	private BisBankSpecialMerchantsDao bisBankSpecialMerchantsDao;
	@Override
	public List<SpecialMerchants> seachEnableSpecialMerchants() {
		return bisBankSpecialMerchantsDao.getEnableSpecialMerchants();
	}
	public BisBankSpecialMerchantsDao getBisBankSpecialMerchantsDao() {
		return bisBankSpecialMerchantsDao;
	}
	public void setBisBankSpecialMerchantsDao(
			BisBankSpecialMerchantsDao bisBankSpecialMerchantsDao) {
		this.bisBankSpecialMerchantsDao = bisBankSpecialMerchantsDao;
	}
	@Override
	public boolean isEnableSpecialMerchant(String merId) {
		List list= bisBankSpecialMerchantsDao.getEnableSpecialMerchantsByMerId(merId);
		if(list!=null&&list.size()!=0){
			return true;
		}else{
			return false;
		}
		
	}
	private static Logger logger = LoggerFactory.getLogger(BisBankSpecialMerchantsManagerImpl.class);
    @Override
    public boolean isEnableBankSpecialMerchant(String merId, String bank) {
        List<SpecialMerchants> list = bisBankSpecialMerchantsDao.getEnableSpecialMerchantsByMerIdBank(merId, bank);
//    	List<SpecialMerchants> list = bisBankSpecialMerchantsDao.getEnableSpecialMerchantsByMerId(merId);
        if (list != null && list.size() > 0) {
			logger.error("查出来的配置：" + list.size());
//        	for(SpecialMerchants chant : list){
//        		logger.error("查出来的配置：" + ToStringBuilder.reflectionToString(chant,ToStringStyle.DEFAULT_STYLE));
//        		if(StringUtils.isEmpty(chant.getRemark()) || StringUtils.equalsIgnoreCase(bank, chant.getRemark())){
//        			logger.error("命中的配置：" + ToStringBuilder.reflectionToString(chant,ToStringStyle.DEFAULT_STYLE));
//        			return true;
//        		}
//        	}
            return true;
//        } else {
//            return false;
        }
        return false;
    }
	
}
